package _go

func generate(numRows int) [][]int {
	if numRows == 0 {
		return [][]int{}
	}
	var res [][]int

	for i := 0; i < numRows; i++ {
		var hang []int
		if i == 0 {
			res = append(res, []int{1})
			continue
		} else if i == 1 {
			res = append(res, []int{1, 1})
			continue
		}

		for j := 0; j <= i; j++ {
			var hang []int
			if j == 0 || j == i {
				hang = append(hang, 1)
			} else {
				val := res[i-1][j] + res[i-1][j-1]
				hang = append(hang, val)
			}
		}
		res = append(res, hang)
	}
	return res
}
